using ZLinq;
using System;
using System.Collections.Generic;
using System.Linq;
using GG.Tool;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEditor;

/// <summary>
/// Zling性能测试
/// </summary>
public class ZLinqExample : MonoBehaviour
{
    public List<int> intList;
   
    void Start()
    {
        intList = Enumerable.Range(1, 1000).ToList();
    }

    // 缓存委托实例，避免重复分配
    private static readonly Func<int, bool> EvenPredicate = x => x % 2 == 0;
    [ChineseName("添加多少个元素")]
    public int addNumber = 256;
    
    void Test1()
    {
        var result = intList.Where(x => x <= 256).ToList();
        EditorApplication.isPaused = true;
    }
    
    void Test2()
    {
        var result = intList.Where(x => x <= 512).ToList();
    }
    
    void Test3()
    {
        var result = intList.Where(x => x <= 512)
            .Select(x => x % 2 == 0 && x % 3 ==0)
            .ToList();
    }

    [Button("开始测试")]
    void TestAll()
    {
        Test1();
        Test2();
        Test3();
        EditorApplication.isPaused = true;
    }
}
